<template>
  <div class="content">
    <!-- header -->

    <!-- <showBox :showdata="showdata"></showBox> -->
    <fromCom :cpnfromdata="cpnfromdata" reffrom="monistForm1" @fromquery="search" />
    <!-- table表格数据 -->
    <div>
      <h3>{{ $route.meta.title }}</h3>
      <el-divider />

      <div style="margin-bottom: 5px">
        <el-button v-permission="permission.export" type="primary" @click="$duduxia({...params11},'/admin/excel/innerTransfer', $route.meta.title)">数据导出</el-button>
        <!-- <el-button type="primary" @click="topexport">数据导出</el-button>  -->
      </div>
      <tableCom :data="datatable" :colum="tabcolum">
        <div class="no-name">
          <!-- <el-table-column
            fixed="right"
            width="200"
            label="操作"
            align="center"
          >
            <template slot-scope="scope">
              <el-button @click="viewDetails(scope.row)" type="text" size="small"
                >查看详情</el-button
              >

            </template>
          </el-table-column> -->
        </div>
      </tableCom>
    </div>
    <!-- page分页 -->
    <div style="text-align:right;margin-top:1rem">
      <paginationCom :page="pagess" @pagetionsc="pagechildchange" />
    </div>
  </div>
</template>

<script>
import { innerTransferPage } from '@/api/jackbo/money.js'
// import { pzselect } from '@/apis/common'
import { colum, fromdata } from './transfer.js'
// import showBox from '@/views/component/showbox'
import fromCom from '@/views/component/fromCom'
import tableCom from '@/views/component/tablecom'
import paginationCom from '@/views/component/pagination'

export default {
  name: 'Transfer',
  components: {
    //  showBox,
    fromCom,
    tableCom,
    paginationCom
  },
  data() {
    return {
      tabcolum: '',
      cpnfromdata: '',
      permission: {
        export: ['admin', 'transfer:export'],
        add: ['admin'],
        edit: ['admin'],
        del: ['admin']
      },
      showdata: [],
      params11: {},
      pagess: {
        page: 1,
        size: 10,
        total: 100
      },
      datatable: []
    }
  },
  created() {
    this.tabcolum = colum
    this.cpnfromdata = fromdata
  },
  mounted() {
    // this.getlist()
    this.querylist()

    // console.log(this.tabcolum, this.cpnfromdata)
  },

  methods: {
    topexport() {
      console.log('我是导出')
    },
    pagechildchange(obj) {
      this.pagess = obj
      this.querylist()
    },
    setobj(data) {
      for (const key in data) {
        data[key] == '' ? (data[key] = null) : data[key]
        data[key] == '155' ? (data[key] = null) : data[key]
        data[key] == undefined ? (data[key] = null) : data[key]
      }
      return data
    },
    querylist() {
      let params = {
        ...this.params11,
        ...this.pagess
      }
      //       params11
      //   console.log(params.orderdate)
      //  params.orderdate.forEach(el=>{
      //    let date=new Date(el)
      //    var time3 = Date.parse(date);
      //    console.log(time3)
      //  })

      if (params.orderdate) {
        let date1 = new Date(params.orderdate[0])
        let date2 = new Date(params.orderdate[1])
        date1 = Date.parse(date1) / 1000
        date2 = Date.parse(date2) / 1000
        params.startDate = date1
        params.endDate = date2
      }

      params = this.setobj(params)
      // this.$showLoading()

      innerTransferPage(params).then(res => {
        this.$hideLoading()

        if (res.code == 0) {
          this.datatable = this.ywtype(res.data.records)
          this.pagess.total = parseInt(res.data.total)
        }
      })
      console.log(params)
    },
    ywtype(arr) {
      // arr.forEach(el => {
      //   if (el.payWay == 0) {
      //     el.payWayname = '微信'
      //   } else if (el.payWay == 1) {
      //     el.payWayname = '银联'
      //   } else {
      //     el.payWayname = '支付宝'
      //   }
      //   if (el.refundStatus == 0) {
      //     el.refundStatusname = '退款中'
      //   } else if (el.refundStatus == 1) {
      //     el.refundStatusname = '退款失败'
      //   } else {
      //     el.refundStatusname = '退款成功'
      //   }
      // })
      return arr
    },
    getlist() {
      const params = {
        ...this.pagess
      }
      refundlist(params).then(res => {
        this.$hideLoading()

        if (res.code == 0) {
          this.datatable = this.ywtype(res.data.records)
          this.pagess.total = parseInt(res.data.total)
          console.log(this.pagess)
        }
      })
      console.log(params)
    },

    viewDetails(obj) {
      console.log(obj)
    },
    ywdel(obj) {
      // 删除
      console.log('我是删除', obj)
    },

    // 搜索
    search(obj) {
      this.params11 = obj
      this.pagess.page = 1
      this.querylist()
    }
  }
}
</script>
<style>
.tableBox th {
  /* padding: 10px !important;
      height: 40px;
      line-height: 40px; */
}

.tableBox td {
  padding: 0 !important;
  height: 50px;
  line-height: 50px;
}

.darge {
  color: rgb(129, 127, 125);
  font-size: 10px;
}
</style>

<style>
@import '../comm.css';
</style>
